$(function() {
	
	setMenu("晋级管理");
	var id = $('#zpId').val();
	$("#pageJinji").page({url:"getUserData",data:{evaluateId:id},success:function(obj){
		$.each(obj.obj.content, function(i,v){
			v.createdAt = new Date(v.createdAt).Format("yyyy.MM.dd");
		});
		$("#pageJinjiTabel").loadData(obj.obj);
		$("span[data='look']").each(function(){
			var text = $(this).attr("data-text");
			if(text != ''){
				var textHtml = "";
				var textObj = eval("("+text+")");
				$.each(textObj, function(i,v){
					textHtml += "<div>"+i+":"+v+"</div>";
				});
				$(this).jjinfo(textHtml);
			}
		});
	}});
	
	$('#worktemplate').on('click',function(){
		var $form = $('<form>').attr({id : "form",method : "get",action : 'work'});
	    $form.appendTo($("#modal"));
	 	$('<input type="hidden">').attr({name : "id",value : $('#zpId').val() }).appendTo($form);
	 	$form.submit();
	});
 
});

function updateApply(id,state){
	if(!confirm("确定要审核这条数据吗？")) {
			return;
		}
	var idp = $('#zpId').val();
	$.ajax({
	  url: 'updateapply',
	  type: 'POST',
	  dataType : "json",
	  data: {
		  idp : idp,
		  id : id,
		  verifyState : state
	  },
	  success: function(obj){
		  if(obj.success){
			  $('#jjCount').text(obj.obj.jjCount);
			  $('#ddCount').text(obj.obj.ddCount);
			  $('#bmCount').text(obj.obj.bmCount);
			  $("#pageJinji").pageReload();
		  }
	  },
	  error : function(r) {
		}
	});
};

function check(id){
	var $temp = $("#userMask").clone();
	$.ajax({
		  url: 'getMedias',
		  type: 'GET',
		  dataType : "json",
		  data: {
			  id : id
		  },
		  success: function(obj){
			  var html = "";
	  			$.each(obj.obj.medias,function(i,v){
	  				if(v.type == "VIDEO"){
	  					html += '<a title="点击播放视频" target="_blank" href="'+v.url+'"><img style="margin-right: 4px;width:200px;height:200px;" onerror="javascript:this.src=\'/img/default2.png\'" src="'+qiniuVideoImg(v.url)+'" /></a>';
	  				} else {
	  					html += '<a title="点击查看图片" target="_blank" href="'+v.url+'"><img style="margin-right: 4px;width:200px;height:200px;" width="200px" height="200px" onerror="javascript:this.src=\'/img/default2.png\'" src="'+v.url+'" /></a>';
	  				}
	  			});
	  			$temp.find('.mask').html(html);
	  			$temp.dilog({title:"作品展示",width:"700px"});
		  },
		  error : function(r) {
			}
		});
}
